<?php

namespace App\Models;

use Illuminate\Auth\Authenticatable;
use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Database\Eloquent\Model;
use Laravel\Lumen\Auth\Authorizable;

/**
 * 管理员用户
 *
 * Class Admin
 * @package App\Models
 *
 * @property int $id 用户id
 * @property string $username 用户名
 * @property string $api_token
 */
class Admin extends Model implements AuthenticatableContract, AuthorizableContract
{
    use Authenticatable, Authorizable;

    protected $guarded = [];

    /**
     * 刷新 api token
     */
    public function refreshApiToken()
    {
        $this->api_token = str_random(60);
    }
}
